<?php
$this->breadcrumbs=array(
		'access',
		'role',
		'manage'
	);
?>


<?php
		Yii::app()->clientScript->registerScript('search', "
		$('.search-button').click(function(){
			$('.search-form').toggle();
			return false;
		});
		$('.search-form form').submit(function(){
			$.fn.yiiGridView.update('role-grid', {
				data: $(this).serialize()
			});
			return false;
		});
		");
?>
<div class="admin_table">
<h1>Manage Role</h1>

<div class="link">
<?php echo CHtml::link('Create New Role',array('role/create')); ?>
</div>
<div class="search_filter">

<?php $form=$this->beginWidget('CActiveForm', array(
	'action'=>Yii::app()->createUrl($this->route),
	'method'=>'get',
)); ?>

	
	<div class="row">
		<?php echo $form->label($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>300)); ?>
	</div>


	<div class="row buttons">
		<?php echo CHtml::submitButton('Search'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- search Filter -->
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->


<?php if(Yii::app()->user->hasFlash('success')):?>
    <div style="color: green;" class="info">
        <?php echo '<b>'.Yii::app()->user->getFlash('success').'</b>'; ?>
    </div>
<?php endif; ?>
<?php
Yii::app()->clientScript->registerScript(
   'myHideEffect',
   '$(".info").animate({opacity: 1.0}, 3000).fadeOut("slow");',
   CClientScript::POS_READY
);
?>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'role-grid',
	'dataProvider'=>$model->search(),
	'columns'=>array(
		array('name'=>'id','htmlOptions'=>array('width'=>'10')),
		array('name'=>'name','htmlOptions'=>array('width'=>'250')),
		array(
			'class'=>'CButtonColumn',
		 	'afterDelete'=>'function(link,success,data){ if(success) $("#statusMsg").html(data); }',
			'template'=>'{update}{delete}{managepermissions}',
			'buttons'=>array(
					'managepermissions'=>array(
							 'label'=>'Manage Permissions',
							 'url'=>'Yii::app()->createUrl("admin/permission/index/id/".$data->id)', 
							 'options'=>array('id'=>'preview_image'),
        					 //'imageUrl'=>BoatConfig::app()->params['theme']['imageUrl'].'view.png'
							 'imageUrl'=>Yii::app()->getBaseUrl().'/images/user-permission.png', 
        					 )					
			),
		
			),
		),
	));
?>	
</div>